package jp.sourceforge.talisman.mds.cluster;

/*
 * $Id: ClusteringParameter.java,v 1.1 2009/09/12 05:06:01 weiwei Exp $
 */

import jp.sourceforge.talisman.mds.Item;
import jp.sourceforge.talisman.mds.distance.DistanceCalculatorFactory;
import jp.sourceforge.talisman.mds.distance.ItemDistanceAlgorithm;
import jp.sourceforge.talisman.mds.distance.ItemDistanceCalculator;

/**
 * 
 * @author Haruaki Tamada
 * @version $Revision: 1.1 $ 
 */
public abstract class ClusteringParameter{
    private ItemDistanceCalculator calculator;
    private int numberOfCluster;

    public abstract boolean isValid(Item[] items);

    public final int getNumberOfCluster(){
        return numberOfCluster;
    }

    public final void setNumberOfCluster(int numberOfCluster){
        if(numberOfCluster <= 0){
            throw new IllegalArgumentException("positive value is required");
        }
        this.numberOfCluster = numberOfCluster;
    }

    public void setDistanceCalculator(ItemDistanceAlgorithm algorithm){
        setDistanceCalculator(DistanceCalculatorFactory.getInstance().getItemDistanceCalculator(algorithm));
    }

    public void setDistanceCalculator(ItemDistanceCalculator calculator){
        this.calculator = calculator;
    }

    public ItemDistanceCalculator getDistanceCalculator(){
        return calculator;
    }
}
